<?php


class db_mysql{
	
	var $db_name;
	var $db_version;
	var $db_pre;
	var $db_config;
	var $db_conn;
	var $db_error;
	function db_mysql($config = array()){
		/**
			$_config['db']['1']['dbhost'] = 'localhost:3306';
			$_config['db']['1']['dbuser'] = 'root';
			$_config['db']['1']['dbpw'] = '';
			$_config['db']['1']['dbcharset'] = 'utf8';
			$_config['db']['1']['pconnect'] = '0';
			$_config['db']['1']['dbname'] = 'discuz';
			$_config['db']['1']['tablepre'] = 'pre_';
		*/
		if(!empty($config))
		{
			$this->db_config = $config;	
		}

		
	}

	/*
	 * 连接数据库
	 * */
	function db_connect($serverId = 1){

	    $db_config = null;
		if(empty($db_config) || empyt($db_config)){
			$this->halt('db_config_not_fount!');
			return false;
		}




	}
	private function _connect(){
		
	}
	function db_error(){
		return $this->db_conn ? mysql_error($this->db_conn) : mysql_error();
	}
	function db_errorno(){
		return $this->db_conn ? mysql_errno($this->db_conn) : mysql_errno();
	}

	/*
		
	*/
    function halt($db_mysql_error){
	    global $_G;
		$this->db_error['err']= $this->db_error();
		$this->db_error['errno'] = $this->db_errorno();
		$this->db_error['db_mysql_error'] = $db_mysql_error;
		$this->db_error['debug'] = debug_backtrace();
		$this->db_error['php'] = '<table style="font-size:11px;border:1px solid red" cellpadding="0"><tr><td width="400">File</td><td width="80">Line</td><td>Function</td></tr>';
		//var_dump(debug_backtrace());
		foreach($this->db_error['debug'] as $err){
            $err[file] = str_replace(DISCUZ_ROOT,'',$err[file]);
		    $this->db_error['php'] .= "<tr><td>$err[file]</td><td>$err[line]</td><td>$err[class]$err[type]$err[function]</td></tr>";



//            $this->db_error['php'] = '<table style="font-size:11px;border:1px solid red" cellpadding="0"><tr><td width="270">File</td><td width="80">Line</td><td>Function</td></tr>';

        }
		$this->db_error['php'] .= "</table>";
		$helplink = "127.0.0.1/?type=mysql%dberrono=".rawurlencode($this->db_error[errno])."&dberror=".rawurlencode($this->db_error['err']);

		//var_dump($_config['output']['charset']);

        /*
         * 526*/
		//@header("Content-Type:text/html;charset=".this->$_config['output']['charset']);


		/*
		 * debug
		 * */
        //echo($this->db_error['php']);
        //var_dump($this->db_error);
	}
	function db_getError(){
		return $this->db_error;
	}
}




?>